<?php
class PreConfiguredDesign extends ObjectModel 
{
    public $id;
    public $id_cms;
    public $namespace;
    public $key_name;
    public $type;
    public $target_element;
    public $style;
    public $default;
    public $active;
    
    public static $definition = array(
        'table' => 'pt_preconfigured_design',
        'primary' => 'id_design',
        'fields' => array(
            'id_cms' => array(
                'type' => ObjectModel::TYPE_INT,
                'required' => true, 
                'validate' => 'isUnsignedId'
            ),
            'namespace' => array(
                'type' => ObjectModel::TYPE_STRING,
                'required' => true,
                'validate' => 'isName',
                'size' => 256,
            ),
            'key_name' => array(
                'type' => ObjectModel::TYPE_STRING,
                'required' => true,
                'validate' => 'isName',
                'size' => 64,
            ),
            'type' => array(
                'type' => ObjectModel::TYPE_STRING,
                'validate' => 'isName',
            ),
            'target_element' => array(
                'type' => ObjectModel::TYPE_STRING,
                'required' => true,
                'validate' => 'isName',
                'size' => 256,
            ),
            'style' => array(
                'type' => ObjectModel::TYPE_STRING,
                'required' => true,
                'validate' => 'isAnything', 
            ),
            'default' => array(
                'type' => ObjectModel::TYPE_BOOL,
                'required' => true,
                'validate' => 'isBool', 
            ),
            'active' => array(
                'type' => ObjectModel::TYPE_BOOL,
                'required' => true,
                'validate' => 'isBool',
            )
        )
    );
    
    public function getCMSName ()
    {
        $cms = new PrestathemeCms ($this->id_cms, Context::getContext()->language->id);
        if ($cms)
            return $cms->getCMSName();
        else
            return NULL;
    }
}